package rtm.core;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class BaseResponseHandler extends DefaultHandler {

	private String status;
	private String errorCode;
	private String errorMsg;

	@Override
	public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
		
		if("rsp".equals(name)) {
			
			status = attributes.getValue("stat");
			
		} else if ("err".equals(name)) {
			
			errorCode = attributes.getValue("code");
			errorMsg = attributes.getValue("msg");
		}
		
		System.out.println("n:" + name);
	}
	
	public boolean isOk() {
		return "ok".equals(status);
	}
	
	public String getStatus() {
		return status;
	}
	
	public String getErrorMsg() {
		return errorMsg;
	}
	
	public String getErrorCode() {
		return errorCode;
	}
}